﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI.WebControls;

namespace SharingCenter.Web.Classes
{
    public class UserSignature : Label
    {
        Guid _uid;
        bool _addHr = true;

        public bool AddHorizontalBar { get { return _addHr; } set { _addHr = value; } }
        public Guid UserId
        {
            get
            {
                return _uid;
            }
            set
            {
                _uid = value;
                string userName = Account.AccountOperations.GetUserNameByUserId(_uid);
                this.Text = WebProfile.GetProfile(userName).Talks.Signature;
            }
        }

        public UserSignature()
        {
            this.PreRender += new EventHandler(UserSignature_PreRender);
        }

        void UserSignature_PreRender(object sender, EventArgs e)
        {
            if (Text.Trim() != string.Empty)
            {
                if (_addHr)
                {
                    this.Text = "<hr/>" + this.Text;
                }
            }
            else
            {
                Visible = false;
            }
        }
    }
}
